home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Source Code / Pascal / Snippets / PNL Libraries / AFPMountVol.p < prev    next >
Encoding:
Text File  |  1996-01-19  |  1.2 KB  |  49 lines  |  [TEXT/CWIE]

  1. unit AFPMountVol;
  2.  
  3. interface
  4.  
  5.     uses
  6.         Types;
  7.  
  8.     function AFPMount (zone, server, vol, user, password: Str32): OSErr;
  9.  
  10. implementation
  11.  
  12.     uses
  13.         Memory,Files;
  14.     
  15.     function AFPMount (zone, server, vol, user, password: Str32): OSErr;
  16.         var
  17.             info: AFPVolMountInfo;
  18.             cur_offset: integer;
  19.  
  20.         function CopyString (s: Str32): integer;
  21.         begin
  22.             CopyString := cur_offset + 23;            (* 23 = header size - 1 (because the AFPData array is 1 based) *)
  23.             BlockMove(@s, @info.AFPData[cur_offset], length(s) + 1);
  24.             cur_offset := cur_offset + length(s) + 1;
  25.         end; (* CopyString *)
  26.  
  27.         var
  28.             pb: ParamBlockRec;
  29.     begin
  30.         info.length := sizeof(info);
  31.         info.media := AppleShareMediaType;
  32.         info.flags := 0;
  33.         info.nbpInterval := 0;
  34.         info.nbpCount := 0;
  35.         info.uamType := kTwoWayEncryptPassword;
  36.         cur_offset := 1;
  37.         info.zoneNameOffset := CopyString(zone);
  38.         info.serverNameOffset := CopyString(server);
  39.         info.volNameOffset := CopyString(vol);
  40.         info.userNameOffset := CopyString(user);
  41.         info.userPasswordOffset := CopyString(password);
  42.         info.volPasswordOffset := CopyString('');
  43.         with pb do begin (* safe *)
  44.             pb.ioBuffer := @info;
  45.         end; (* with *)
  46.         AFPMount := PBVolumeMount(@pb);
  47.     end; (* AFPMount *)
  48.  
  49. end. (* AFPMountVol *)